package com.eastjet.maintenance.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eastjet.maintenance.domain.Purchasedetails;
import com.eastjet.maintenance.domain.Purchaseorder;
import com.eastjet.maintenance.mapper.PurchasedetailsMapper;
import com.eastjet.maintenance.service.PurchasedetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 杨博文
 * @description 针对表【purchasedetails(采购明细)】的数据库操作Service实现
 * @createDate 2024-11-25 09:23:39
 */
@Service
public class PurchasedetailsServiceImpl extends ServiceImpl<PurchasedetailsMapper, Purchasedetails> implements PurchasedetailsService {

    @Autowired
    private PurchasedetailsMapper purchasedetailsMapper;// 注入PurchasedetailsMapper

    /*
     * 新增采购明细
     */
    @Override
    public Boolean InsertPurchasedetails(List<Purchasedetails> purchasedetails) {
        return this.saveBatch(purchasedetails);
    }

    /*

    修改采购明细
     */
    @Override
    public Boolean UpdatePurchasedetails(List<Purchasedetails> purchasedetails) {
        return this.updateBatchById(purchasedetails);
    }

    /*
     * 删除采购明细
     */
    @Override
    public Boolean DeletePurchasedetails(List<String> ids) {
        return this.removeByIds(ids);
    }

    /*
     * 根据采购单号查询采购明细
     */
    @Override
    public List<Purchasedetails> selectPurchasedetailsById(String code) {
        return this.list(new QueryWrapper<Purchasedetails>().and(i -> i.eq("request_number", code).eq("tombstone", "0")));
    }

    /**
     * 根据采购单号查询采购明细
     *
     * @param code
     * @return
     */
    @Override
    public List<Purchasedetails> selectPurchasedetailsByCode(Purchasedetails purchasedetails) {
        return purchasedetailsMapper.selectPurchasedetailsByCode(purchasedetails);
    }

}




